<extend name="Public/common" />
<block name="body">
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>排餐管理</h3>
      <ul class="tab-base">
        <li><a href="JavaScript:void(0);" class="current"><span>列表</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form method="get" action="{:U('send')}" name="form_search">
    <table class="tb-type1 noborder search">
      <tbody>
        <tr>
          <th><label>订单号或收货人电话</label></th>
          <td><input type="text" value="<notempty name="get.keyword">{$get.keyword}</notempty>" name="keyword" id="keyword" class="txt"></td>
          <th><label>商户名称</label></th>
          <td>
               <div id="store_name_box" class="store-list">请输入商户名称</div>
               <input type="text" value="<notempty name="get.store_name">{$get.store_name}</notempty>" id="store_name" name="store_name" class="text" oninput="ajax_store_name();" onpropertychange="ajax_store_name();" autocomplete="off" >
               <input type="hidden" id="store_id" name="store_id" value="<notempty name="get.store_id">{$get.store_id}</notempty>">
          </td>
          <th><label>订单状态</label></th>
          <td>
            <select class="querySelect" name="order_state">
              <option <if condition="(isset($get['order_state'])) && ($get['order_state'] === '')">selected='selected'</if> value="">请选择...</option>
              <option <if condition="(isset($get['order_state'])) && ($get['order_state'] === 0)">selected='selected'</if> value="0">已取消</option>
              <option <if condition="(isset($get['order_state'])) && ($get['order_state'] == 1)">selected='selected'</if> value="1">未付款</option>
              <option <if condition="(isset($get['order_state'])) && ($get['order_state'] == 2)">selected='selected'</if> value="2">已付款</option>
              <option <if condition="(isset($get['order_state'])) && ($get['order_state'] == 3)">selected='selected'</if> value="3">已发货</option>
              <option <if condition="(isset($get['order_state'])) && ($get['order_state'] == 4)">selected='selected'</if> value="4">已收货</option>
            </select>
          </td>

          <th><label>会员昵称或OPENID</label></th>
          <td><input type="text" value="<notempty name="get.nickname">{$get.nickname}</notempty>" name="nickname" id="nickname" class="txt"></td>

          <td>
          	<a href="javascript:document.form_search.submit();" class="btn-search " title="查询">&nbsp;</a>
            <notempty name="get">
              <a href="{:U('send')}" class="btns " title="撤销检索"><span>撤销检索</span></a>
            </notempty>
          </td>
        </tr>
        <tr>

          <th><label>送餐日期:</label></th>
          <td>
            <input class="txt date" type="text" value="<notempty name="get.start_create_time">{$get['start_create_time']}</notempty>" id="start_create_time" name="start_create_time">
            -
            <input class="txt date" type="text" value="<notempty name="get.end_create_time">{$get['end_create_time']}</notempty>" id="end_create_time" name="end_create_time">
          </td>

          <th><label>楼宇：</label></th>
          <td id="region_id" colspan="8">
            <select class="querySelect" name="region_id">
              <option value="">请选择...</option>
              <notempty name="region">
                <volist name="region" id="vo">
                  <option <notempty name="get.region_id"><eq name="get.region_id" value="$key">selected='selected'</eq></notempty> value="{$key}">{$vo}</option>
                </volist>
              </notempty>
            </select></td>
          <td>


        </tr>
      </tbody>
    </table>
  </form>
<table class="table tb-type2" id="prompt">
	<tbody>
		<tr class="space odd">
			<th colspan="12"><div class="title"><h5>操作提示</h5><span class="arrow"></span></div></th>
		</tr>
		<tr>
			<td><ul>
    <li>点击查看操作将显示订单（包括订单物品）的详细信息</li>
				</ul></td>
		</tr>
	</tbody>
</table>
	<form method="post" action="{:U('changeState')}" id="form1">
    <table class="table tb-type2">
      <thead>
      <!--属于订单编号 区域 商户 餐品 昵称 用户ID  买家 电话 楼宇 地址-->
      <!--筛选项-->
      <!--区域 配送日期-->
      <!--查询项-->
      <!--电话 昵称-->

      <tr class="thead">
        <th class="w24"></th>
          <th>订单编号</th>
          <th class="w84 align-center">区域</th>
          <th class="w84 align-center">菜单日期</th>
          <th class="w84 align-center">商户</th>
          <th class="w120 align-center">菜品</th>
          <th class="w60 align-center">菜品数量</th>
          <th class="w60 align-center">昵称</th>
          <th class="align-center">用户ID</th>
          <th class="w60 align-center">买家</th>
          <th class="w60 align-center">电话</th>
          <th class="w108 align-center">楼宇</th>
          <th class="w108 align-center">地址</th>
          <th class="w60 align-center">订单总额</th>
          <th class="w60 align-center">订单状态</th>
          <th class="w60 align-center">支付状态</th>
          <th class="w120 align-center">下单时间</th>
          <th class="w120 align-center">操作</th>
        </tr>
      </thead>
      <tbody>
        <notempty name="list">
        <volist name="list" id="vo">
        <tr class="hover">
          <td><input type="checkbox" name='id[]' value="{$vo['id']}" class="checkitem"></td>
          <td>{$vo['order_sn']}</td>
          <td class="align-center">{$area[$vo['area_id']]}</td>
          <td class="align-center">{:date('Y-m-d', $vo['menu_date'])}</td>
          <td class="align-center">{$store[$vo['store_id']]}</td>
          <td class="align-center">{$vo['goods_name']}</td>
          <td class="align-center">{$vo['goods_num']}</td>
          <td class="align-center">{$vo['nickname']}</td>
          <td class="align-center">{$vo['member_id']}</td>
          <td class="align-center">{$vo['reciver_name']}</td>
          <td class="align-center">{$vo['reciver_phone']}</td>
          <td class="align-center">{$vo['region_name']}</td>
          <td class="align-center">{$vo['address']}</td>
          <td class="align-center">{$vo['order_amount']}</td>
          <td class="align-center">{:getOrderState($vo['order_state'])}</td>
          <td class="align-center"><eq name="vo.pay_state" value="1">已支付<else />未支付</eq></td>
          <td class="align-center">{$vo['create_time']|time_format}</td>
          <td class="align-center">
          	<a href="{:U('view?id='.$vo['order_id'])}">查看</a>
          	<a href="{:U('edit?id='.$vo['id'])}">更改状态</a>
          </td>
        </tr>
        </volist>
        <else />
        <tr class="no_data">
          <td colspan="10">没有符合条件的记录</td>
        </tr>
        </notempty>
      </tbody>
      <tfoot>
        <tr class="tfoot">
        <notempty name="page">
          <td><input type="checkbox" class="checkall" id="checkallBottom"></td>
          <td><label for="checkallBottom">全选</label></td>
          <td colspan="16">
          <select class="querySelect" name="order_state">
            <option value="">请选择...</option>
            <option value="0">已取消</option>
            <option value="1">未付款</option>
            <option value="2">已付款</option>
            <option value="3">已发货</option>
            <option value="4">已收货</option>
          </select>
          &nbsp;&nbsp;<a href="JavaScript:void(0);" class="btn" onclick="if(confirm('您确定要更改订单状态吗?')){$('#form1').submit();}"><span>提交</span></a>
            <a href="{$export_url}" target="_blank" class="btn"><span>导出数据</span></a>
            <div class="pagination"> {$page} </div>
          </td>
         <else />  
          <td colspan="16"></td>
         </notempty>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
  <script type="text/javascript" src="__JS__/jquery-ui/jquery.ui.js"></script>
  <script type="text/javascript" src="__JS__/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
  <link rel="stylesheet" type="text/css" href="__JS__/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<script type="text/javascript">
     function ajax_store_name(){
        $('#store_name_box').show();
        var store_name = $('#store_name').val();
        $.post("{:U('admin/store/ajax')}", { "store_name" : store_name }, function(data) {
            var data = $.parseJSON(data);
            if(data){
                if (data.length > 0)
                {
                    var html = '<ul style="max-height:200px; overflow-y:scroll">';
                    var data = data;
                    for (i = 0; i < data.length; i++)
                    {
                    	html += '<a href="javascript:sel(\'' + data[i].store_id + '\', \'' + data[i].store_name + '\')"><li>' + data[i].store_name + '</li></a>';
                    }
                    html += '</ul>';
                    $('#store_name_box').html(html);
                }
            }
        });
    }
	function sel(store_id, store_name) {
		if (store_id == '0') {
			$('#store_name').val('').focus();
			$('#store_name_box').hide();
		} else {
			$('#store_name').val(store_name);
			$('#store_id').val(store_id);
			$('#store_name_box').hide();
		}
	}
     $(document).ready(function(){
       $('#start_create_time').datepicker({dateFormat: 'yy-mm-dd'});
       $('#end_create_time').datepicker({dateFormat: 'yy-mm-dd'});
     });
</script>
</block>